// 这个文件中的测试与 express 和 mongodb 无关


function Mongoose() {

}

// 为 Mongoose 对象(class-levle)的原型 添加一个名称是 Model 的对象(class-levle)
Mongoose.prototype.Model = function() {

}

// 为 Mongoose.prototype.Model 对象(class-levle) 添加 静态函数
Mongoose.prototype.Model.create = function() {
    return new Mongoose.prototype.Model();
}

Mongoose.prototype.Model.prototype.eat = function(food) {
    console.log(`吃${food}`);
}

Mongoose.prototype.Model.prototype.run = function() {
    console.log(`跑`);
}

Mongoose.prototype.model = function() {

    let c = function() {

    }

    c.prototype = new Mongoose.prototype.Model();
    c.prototype.constructor = c;

    //将Mongoose.prototype.Model的属性函数枚举到c
    Object.assign(c, Mongoose.prototype.Model);

    return c;
}

let mongoose = new Mongoose();

let M = mongoose.model();

let m = new M();

console.log(m.constructor === M);

let x = M.create();
console.log(x.constructor === M);
console.log(x)
console.log(M)

m.eat('藜蒿炒腊肉');
x.eat('李浩炒腊肉');